package com.magicode.cms.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import com.magicode.cms.dao.INewsProgramRelaDao;
import com.magicode.cms.dao.IOfflineEventsEnterpriseDao;
import com.magicode.cms.entiy.base.NewsProgramRela;
import com.magicode.cms.entiy.base.OfflineEventsEnterprise;
import com.magicode.cms.service.INewsProgramRelaService;
import com.magicode.cms.service.IOfflineEventEnterpriseService;

@Service("serviceofflineEventEnterprise")
public class offlineEventEnterpriseServiceImpl extends BaseServiceImpl<OfflineEventsEnterprise,IOfflineEventsEnterpriseDao>  implements IOfflineEventEnterpriseService{

	@Autowired
	@Qualifier("offlineEventEnterpriseDao")
	private IOfflineEventsEnterpriseDao eventsEnterpriseDao;
	
	@Override
	public String getHql(Map<String, String> map) throws Exception {
		String hql ="from " +OfflineEventsEnterprise.class.getName()+" "+entity_alias_name+" where 1 = 1 ";
		if(null!=map && !map.isEmpty()){
			if(map.containsKey(field_id)){
				hql = hql+" and "+entity_alias_name+".id = '"+map.get(field_id)+"'";
			}
		}
		
		return hql;
	}
	@Override
	public List<Map<String, Object>> getBeanInfo() {
		return null;
		
	}
	@Override
	public List<Map<String, Object>> grid(Map<String, String> querywhere) {
		return null;
		
	}
	@Override
	public List<Map<String,Object>> select(Map<String,String> querywhere){
		return null;
		
	}
	@Override
	public OfflineEventsEnterprise getSourceByTitle(String name) throws Exception {
		try {
			Map<String,String> map = new HashMap<String,String> ();
			map.put("title", name);
			List<OfflineEventsEnterprise> sources = this.getDao().queryDataList(this.getHql(map), 0, 0);
			return  sources.size()==1?sources.get(0) : null;
		} catch (Exception e) {
			//throw new Exception("getSourceByTitle error by email=["+name+"]"+e.getMessage());
			throw new Exception("getSourceByTitle error by title=["+name+"]"+e.getMessage());
		}
	}
	@Override
	public IOfflineEventsEnterpriseDao getDao() throws Exception {
		return eventsEnterpriseDao;
	}
	
	@Override
	public void deletecoSponsorEnts(String userid) throws Exception {
		eventsEnterpriseDao.deletecoSponsorEnts(userid);
		
	}
	@Override
	public void deleteSponsorEnts(String offEvnid) throws Exception {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void deleteAllSponsorEnts(String offEvnid) throws Exception {
		// TODO Auto-generated method stub
		
	}
}
